<script setup>
import { getChannelsAPI } from '@/api/article'
import { ref, onMounted } from 'vue'

// 接收 父组件的 分类id
defineProps({
  modelValue: [Number, String]
})
// 传递 父组件的 分类id
const emit = defineEmits(['update:modelValue'])
// 获取文章分类
const articleList = ref([])
const getArticleList = async () => {
  const {
    data: { data }
  } = await getChannelsAPI()
  articleList.value = data
}
onMounted(() => {
  getArticleList()
})
</script>

<template>
  <el-select
    :modelValue="modelValue"
    @update:modelValue="emit('update:modelValue', $event)"
    placeholder="请选择"
    style="width: 240px"
  >
    <el-option
      v-for="item in articleList"
      :key="item.id"
      :label="item.cate_name"
      :value="item.id"
    />
  </el-select>
</template>
